#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> missingTwo(vector<int>& nums) {
        int x = 0;
        int n = nums.size() + 2;
        for (auto e : nums) {
            x ^= e;
        }
        for (int i = 1; i <= n; i++) {
            x ^= i;
        }
        //  int l = x == INT_MIN ? x : x & (-x);
        int diff = 0;
        while (1) {
            if (((x >> diff) & 1) == 1)
                break;
            diff++;
        }
        int t1 = 0, t2 = 0;
        for (auto e : nums) {
            if ((e >> diff & 1) == 1)
                t1 ^= e;
            else
                t2 ^= e;
        }
        for (int i = 1; i <= n; i++) {
            if ((i >> diff & 1) == 1)
                t1 ^= i;
            else
                t2 ^= i;
        }
        return { t1, t2 };
    }
};